package de.hrw.androidapp.util;

import java.util.ArrayList;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/**
 * @author tvh-dev
 *
 */
public class CanceledCoursesXMLParser 
extends XMLParser 
{
	/**
	 *	Constructor.
	 * 
	 * @param xmlUrl
	 */
	public CanceledCoursesXMLParser(String xmlUrl) 
	{
		super(xmlUrl);
	}

	/* (non-Javadoc)
	 * @see de.hrw.androidapp.util.XMLParserInterface#parse()
	 */
	@Override
	public ArrayList<String> parse() 
	{
		Elements itemElements = doc.select("item");

		ArrayList<String> canceledCoursesList = new ArrayList<String>();

		if (itemElements.size() > 0)
		{
			for (int i = 0; i < itemElements.size(); i++)
			{
				Element itemElement = itemElements.get(i);
				
				String title = itemElement.select("title").text();
				String html = Jsoup.parse(title).text();
				canceledCoursesList.add(html);
			}
		}
		else
		{
			canceledCoursesList.add("Heute keine ausfallenden Veranstaltungen!");
		}
		
		return canceledCoursesList;
	}
}
